home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 4.7 KB | 89 lines | [TEXT/GEOL] |
- Item forwarded by A33 to A34
-
- Item forwarded by LOOMIS to GUITTET1
-
- Item forwarded by LOOMIS to COWSAR1 PLUMMER1 REKIETA1
-
- Item 4067071 19-April-90 10:19PDT
-
- From: KEMINK1 Kemink, Joost
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: More on external code
-
- MacAppers,
-
- Since my car broke down this morning and thus forced me (sort of) to work at my
- home office (which is just a Mac on a table), I thought I might as well add
- some thoughts to the external code discussion.
-
- In Xenon (discrete time finite duration signal processing), CUST resources are
- used to implement the signal processing functions. Without any CUST resources,
- the application "works" but has no functionality.
-
- The user builds signal chains by dragging "Elements" into a view and connecting
- these Elements together by "Connections". Each Element represents some signal
- processing functionality such as a generator (an Element that creates data) or
- an operator (an Element that transforms data). Elements can have zero or more
- inputs and/or zero or more outputs. Elements may have parameters as well.
-
- Due to the limited nature of the CUST resources in Xenon, each CUST resource
- only has a few subroutines (the appropriate one is identified by a routine
- selector, much like it is done in HyperCard). These routines are (roughly):
- Initialize, Free, Calculate and ModifyParameters. Initialize and Free allocate
- and release data needed by the CUST respectively. Calculate is the routine
- where the signal processing takes place, given any input data and parameters.
- ModifyParameters gets called when the user double-clicks on an Element. If, for
- example, the user double-clicks on a delay Element, a dialog box shows up that
- allows the user the adjust the delay.
-
- Since these dialogs generally involve the user to type in some value, or maybe
- even adjust a slider control or something like that, it would require a lot of
- code to implement all these common things in every separate CUST resource. At
- this point, callbacks become useful.
- In some tests I did, the CUST resource is stored in a separate file together
- with a VIEW resource, and some other resources like PICT's and ICON's. When the
- CUST's ModifyParameters routine is being called, the CUST calls back a MacApp
- internal routine which creates a window with NewTemplateWindow, using the VIEW
- resource in the external code. The window is not yet displayed, since the
- values for various NumberText items may need to be adjusted to reflect the
- current parameter values. Once the MacApp internal routine returns,
- ModifyParameters adjusts the required NumberTexts by calling another MacApp
- internal which in turn calls the appropriate MacApp TNumberText method. Finally
- when all the values are set up correctly, ModifyParameters calls yet another
- MacApp internal which in turn calls PoseModally. Depending on the result of
- PoseModally, the external code either accepts the parameter changes or rejects
- them, and finally closes the window (yes, again by calling a MacApp internal).
-
- From the scenario above, it follows that the mechanism needs quite a number of
- callbacks to the host application. As Keith mentioned, the set of callbacks may
- vary from application to application. Therefore I like his proposal of
- designing things according to function.
-
- With respect to resource ID's, with Xenon I very quickly ran into problems with
- duplicate resource ID's when several people who wrote CUST resources
- independently wanted to add them to the host. In recent tests, I switched from
- resource ID's to resource names as the mechanism to select CUST's. Of course,
- name conflicts may arise as well, but they are less likely than ID conflicts.
- To reduce possible conflicts even further, I think that every 'package' should
- be contained in its own file. ('Package' being CUST resource plus possible
- other resources needed by it).
-
- CUST's in Xenon are encapsulated in an object, the CUST's routines are called
- by corresponding methods in the object. In later tests, where the application
- continuously looks for external code in files, a "manager" takes care of
- searching one or more folders. A practical problem that arises here is the
- possibility that users can put external code files in folders and remove them
- later, this could very easily confuse the host application. Also, you have to
- very closely keep track of the resource chain, since you would like the host
- application to have access to its STR# resources to display an error message
- when the user enters an out-of-bounds value in the VIEW provided by the
- external code.
-
- Hoping this adds to the interesting external code discussion, I remain without
- a car,
-
- Joost Kemink
-
-